package com.egreen.user.controller;


import com.egreen.common.Result;
import com.egreen.common.States;
import com.egreen.common.pojo.DTO.user.userServiceDTO.ApplicationForAgencyDTO;
import com.egreen.user.service.IAgentApplicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author cloudJiang
 * @since 2022-07-26
 */
@RestController
@RequestMapping("/agentApplication")
@Api("代理申请接口")
public class AgentApplicationController {
    @Autowired
    IAgentApplicationService agentApplicationService;


    @ApiOperation(value = "代理申请", notes = "通过调用applicationForAgency方法，完成代理申请")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "agencyType", value = "用户申请的代理类型", required = true),
            @ApiImplicitParam(name = "userName", value = "用户名", required = true),
            @ApiImplicitParam(name = "phone", value = "手机号", required = true),
            @ApiImplicitParam(name = "email", value = "邮箱", required = true),
            @ApiImplicitParam(name = "password", value = "密码", required = true),
            @ApiImplicitParam(name = "invitationCode", value = "邀请码"),
            @ApiImplicitParam(name = "province", value = "省份", required = true),
            @ApiImplicitParam(name = "city", value = "城市", required = true),
            @ApiImplicitParam(name = "district", value = "区域", required = true),
            @ApiImplicitParam(name = "community", value = "社区", required = true),
            @ApiImplicitParam(name = "locationDetails", value = "详细地址", required = true),
            @ApiImplicitParam(name = "validCode", value = "验证码"),
            @ApiImplicitParam(name = "applicationForAgencyDTO", value = "以上十个参数封装在此DTO中")
    })
    /*
     * 代理申请
     */
    @PostMapping("/applicationForAgency")
    Result applicationForAgency(@Validated @RequestBody ApplicationForAgencyDTO applicationForAgencyDTO) {
        agentApplicationService.applicationForAgency(applicationForAgencyDTO);
        return new Result(null, 20000, "代理申请成功，请耐心等待验证，验证通过将以邮件方式通知您。" +
                "与此同时您也可以通过申请信息登陆系统体验");
    }
}

